package com.xlobo.api.fund.testcase;

import java.util.Map;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.xlobo.api.fund.parameter.RechargeBean;
import com.xlobo.api.fund.service.RechargeCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymt.utils.tag.P2;
import com.ymt.utils.tag.P3;
import com.ymttest.business.service.XloboAccountCallService;
import com.ymttest.utils.TestDataManager;

/**
 * 账户充值 FreeMaker Template自动生成代码
 */
@TestSuite
public class Ts_Recharge {
	private static RechargeBean rechargebean;
	private static RechargeCall rechargecall;

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("账户充值");
	}

	@Before
	public void caseUp() {
		rechargebean = new RechargeBean();
		rechargecall = new RechargeCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(rechargecall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_Recharge_001() {
		Logger.start(true,"账户充值（根据 UserId + AccountType）,充值成功");
		try {
			int AccountType = 0;
			Map<?, ?> map = XloboAccountCallService.getAccount(AccountType);// 生成UserId
			// 用户Id
			String UserId = (String) map.get("UserId");
			Logger.comment("用户UserID:" + UserId);
			rechargebean.setUserId(UserId);
			// 充值金额
			Double RechargeAmount = 10.00;
			Logger.comment("充值金额:" + RechargeAmount);
			rechargebean.setRechargeAmount(RechargeAmount);
			// 金额类型
			Integer AmountType = 0;
			Logger.comment("金额类型:" + AmountType);
			rechargebean.setAmountType(AmountType);
			// 业务编号
			String BusinessId = TestDataManager.getClientpaymentId();
			Logger.comment("业务编号:" + BusinessId);
			rechargebean.setBusinessId(BusinessId);
			// 业务类型
			Integer BusinessType = 202;
			Logger.comment("业务类型:" + BusinessType);
			rechargebean.setBusinessType(BusinessType);
			// 账户类型
			Integer UserAccountType = 0;
			Logger.comment("账户类型:" + UserAccountType);
			rechargebean.setUserAccountType(UserAccountType);
			// 系统来源
			Integer SystemSource = 7;
			Logger.comment("系统来源:" + SystemSource);
			rechargebean.setSystemSource(SystemSource);
			// 备注
			String Comment = "自动化测试";
			Logger.comment("备注:" + Comment);
			rechargebean.setComment(Comment);
			// 请求编号
			String RequestId = TestDataManager.getRandomUUID() + "";
			Logger.comment("请求编号:" + RequestId);
			rechargebean.setRequestId(RequestId);
			// 发送请求
			rechargecall.setData(rechargebean);
			rechargecall.callService();
			// 验证
			Logger.comment("rechargecall send:" + rechargecall.getEntityString());
			Logger.comment("rechargecall response:" + rechargecall.getReturnData());
			Logger.verifyEquals("ok", rechargecall.getStatus(), "响应状态验证");
			Logger.verifyNotNull(rechargecall.getMessage(), "响应信息账户金额");
			// TODO RequestId目前未生效，不会在响应中返回，暂不验证
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_Recharge_002() {
		Logger.start(true,"账户充值（根据 UserId + AccountType）,User为空,充值失败");
		try {
			// int AccountType = 0;
			// Map<?, ?> map =
			// AccountCallService.getAccount(AccountType);//生成UserId
			// 用户Id
			// String UserId = (String) map.get("UserId");
			// Logger.comment("用户UserID:"+UserId);
			// rechargebean.setUserId(UserId);
			// 充值金额
			Double RechargeAmount = 10.00;
			Logger.comment("充值金额:" + RechargeAmount);
			rechargebean.setRechargeAmount(RechargeAmount);
			// 金额类型
			Integer AmountType = 0;
			Logger.comment("金额类型:" + AmountType);
			rechargebean.setAmountType(AmountType);
			// 业务编号
			String BusinessId = TestDataManager.getClientpaymentId();
			Logger.comment("业务编号:" + BusinessId);
			rechargebean.setBusinessId(BusinessId);
			// 业务类型
			Integer BusinessType = 202;
			Logger.comment("业务类型:" + BusinessType);
			rechargebean.setBusinessType(BusinessType);
			// 账户类型
			Integer UserAccountType = 0;
			Logger.comment("账户类型:" + UserAccountType);
			rechargebean.setUserAccountType(UserAccountType);
			// 系统来源
			Integer SystemSource = 7;
			Logger.comment("系统来源:" + SystemSource);
			rechargebean.setSystemSource(SystemSource);
			// 备注
			String Comment = "自动化测试";
			Logger.comment("备注:" + Comment);
			rechargebean.setComment(Comment);
			// 请求编号
			String RequestId = TestDataManager.getRandomUUID() + "";
			Logger.comment("请求编号:" + RequestId);
			rechargebean.setRequestId(RequestId);
			// 发送请求
			rechargecall.setData(rechargebean);
			rechargecall.callService();
			// 验证
			Logger.comment("rechargecall send:" + rechargecall.getEntityString());
			Logger.comment("rechargecall response:" + rechargecall.getReturnData());
			Logger.verifyEquals("request.userId参数验证错误", rechargecall.getMessage(), "错误响应信息验证");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_Recharge_003() {
		Logger.start(true,"账户充值（根据 UserId + AccountType）,AccountType不正确,充值失败");
		try {
			int AccountType = 0;
			Map<?, ?> map = XloboAccountCallService.getAccount(AccountType);// 生成UserId
			// 用户Id
			String UserId = (String) map.get("UserId");
			Logger.comment("用户UserID:" + UserId);
			rechargebean.setUserId(UserId);
			// 充值金额
			Double RechargeAmount = 10.00;
			Logger.comment("充值金额:" + RechargeAmount);
			rechargebean.setRechargeAmount(RechargeAmount);
			// 账户类型
			Integer UserAccountType = 0;
			Logger.comment("账户类型:" + UserAccountType);
			rechargebean.setUserAccountType(UserAccountType);
			// 金额类型
			Integer AmountType = 1000;
			Logger.comment("金额类型:" + AmountType);
			rechargebean.setAmountType(AmountType);
			// 业务编号
			String BusinessId = TestDataManager.getClientpaymentId();
			Logger.comment("业务编号:" + BusinessId);
			rechargebean.setBusinessId(BusinessId);
			// 业务类型
			Integer BusinessType = 202;
			Logger.comment("业务类型:" + BusinessType);
			rechargebean.setBusinessType(BusinessType);
			// 系统来源
			Integer SystemSource = 7;
			Logger.comment("系统来源:" + SystemSource);
			rechargebean.setSystemSource(SystemSource);
			// 备注
			String Comment = "自动化测试";
			Logger.comment("备注:" + Comment);
			rechargebean.setComment(Comment);
			// 请求编号
			String RequestId = TestDataManager.getRandomUUID() + "";
			Logger.comment("请求编号:" + RequestId);
			rechargebean.setRequestId(RequestId);
			// 发送请求
			rechargecall.setData(rechargebean);
			rechargecall.callService();
			// 验证
			Logger.comment("rechargecall send:" + rechargecall.getEntityString());
			Logger.comment("rechargecall response:" + rechargecall.getReturnData());
			Logger.verifyEquals("未找到该金额类型", rechargecall.getMessage(), "错误响应信息验证");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_Recharge_004() {
		Logger.start(true,"账户充值（根据 UserId + AccountType）,UserID与AccountType不一致,充值失败");
		try {
			int AccountType = 0;
			Map<?, ?> map = XloboAccountCallService.getAccount(AccountType);// 生成UserId
			// 用户Id
			String UserId = (String) map.get("UserId");
			Logger.comment("用户UserID:" + UserId);
			rechargebean.setUserId(UserId);
			// 充值金额
			Double RechargeAmount = 10.00;
			Logger.comment("充值金额:" + RechargeAmount);
			rechargebean.setRechargeAmount(RechargeAmount);
			// 金额类型
			Integer AmountType = 0;
			Logger.comment("金额类型:" + AmountType);
			rechargebean.setAmountType(AmountType);
			// 业务编号
			String BusinessId = TestDataManager.getClientpaymentId();
			Logger.comment("业务编号:" + BusinessId);
			rechargebean.setBusinessId(BusinessId);
			// 业务类型
			Integer BusinessType = 202;
			Logger.comment("业务类型:" + BusinessType);
			rechargebean.setBusinessType(BusinessType);
			// 账户类型
			Integer UserAccountType = 1;
			Logger.comment("账户类型:" + UserAccountType);
			rechargebean.setUserAccountType(UserAccountType);
			// 系统来源
			Integer SystemSource = 7;
			Logger.comment("系统来源:" + SystemSource);
			rechargebean.setSystemSource(SystemSource);
			// 备注
			String Comment = "自动化测试";
			Logger.comment("备注:" + Comment);
			rechargebean.setComment(Comment);
			// 请求编号
			String RequestId = TestDataManager.getRandomUUID() + "";
			Logger.comment("请求编号:" + RequestId);
			rechargebean.setRequestId(RequestId);
			// 发送请求
			rechargecall.setData(rechargebean);
			rechargecall.callService();
			// 验证
			Logger.comment("rechargecall send:" + rechargecall.getEntityString());
			Logger.comment("rechargecall response:" + rechargecall.getReturnData());
			Logger.verifyEquals("未找到该用户的账户信息", rechargecall.getMessage(), "错误响应信息验证");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_Recharge_005() {
		Logger.start(true,"账户充值（根据 UserId + AccountType）,UserID不存在,充值失败");
		try {
			String UserId = "1";
			Logger.comment("用户UserID:" + UserId);
			rechargebean.setUserId(UserId);
			// 充值金额
			Double RechargeAmount = 10.00;
			Logger.comment("充值金额:" + RechargeAmount);
			rechargebean.setRechargeAmount(RechargeAmount);
			// 金额类型
			Integer AmountType = 0;
			Logger.comment("金额类型:" + AmountType);
			rechargebean.setAmountType(AmountType);
			// 业务编号
			String BusinessId = TestDataManager.getClientpaymentId();
			Logger.comment("业务编号:" + BusinessId);
			rechargebean.setBusinessId(BusinessId);
			// 业务类型
			Integer BusinessType = 202;
			Logger.comment("业务类型:" + BusinessType);
			rechargebean.setBusinessType(BusinessType);
			// 账户类型
			Integer UserAccountType = 1;
			Logger.comment("账户类型:" + UserAccountType);
			rechargebean.setUserAccountType(UserAccountType);
			// 系统来源
			Integer SystemSource = 7;
			Logger.comment("系统来源:" + SystemSource);
			rechargebean.setSystemSource(SystemSource);
			// 备注
			String Comment = "自动化测试";
			Logger.comment("备注:" + Comment);
			rechargebean.setComment(Comment);
			// 请求编号
			String RequestId = TestDataManager.getRandomUUID() + "";
			Logger.comment("请求编号:" + RequestId);
			rechargebean.setRequestId(RequestId);
			// 发送请求
			rechargecall.setData(rechargebean);
			rechargecall.callService();
			// 验证
			Logger.comment("rechargecall send:" + rechargecall.getEntityString());
			Logger.comment("rechargecall response:" + rechargecall.getReturnData());
			Logger.verifyEquals("request.userId参数验证错误", rechargecall.getMessage(), "错误响应信息验证");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_Recharge_006() {
		Logger.start(true,"账户充值（根据 UserId + AccountType）,业务编号已存在,充值失败");
		try {
			String UserId = "1";
			Logger.comment("用户UserID:" + UserId);
			rechargebean.setUserId(UserId);
			// 充值金额
			Double RechargeAmount = 10.00;
			Logger.comment("充值金额:" + RechargeAmount);
			rechargebean.setRechargeAmount(RechargeAmount);
			// 金额类型
			Integer AmountType = 0;
			Logger.comment("金额类型:" + AmountType);
			rechargebean.setAmountType(AmountType);
			// 业务编号
			String BusinessId = TestDataManager.getClientpaymentId();
			Logger.comment("业务编号:" + BusinessId);
			rechargebean.setBusinessId(BusinessId);
			// 业务类型
			Integer BusinessType = 202;
			Logger.comment("业务类型:" + BusinessType);
			rechargebean.setBusinessType(BusinessType);
			// 账户类型
			Integer UserAccountType = 1;
			Logger.comment("账户类型:" + UserAccountType);
			rechargebean.setUserAccountType(UserAccountType);
			// 系统来源
			Integer SystemSource = 7;
			Logger.comment("系统来源:" + SystemSource);
			rechargebean.setSystemSource(SystemSource);
			// 备注
			String Comment = "自动化测试";
			Logger.comment("备注:" + Comment);
			rechargebean.setComment(Comment);
			// 请求编号
			String RequestId = TestDataManager.getRandomUUID() + "";
			Logger.comment("请求编号:" + RequestId);
			rechargebean.setRequestId(RequestId);
			// 发送请求
			rechargecall.setData(rechargebean);
			rechargecall.callService();
			// 验证
			Logger.comment("rechargecall send:" + rechargecall.getEntityString());
			Logger.comment("rechargecall response:" + rechargecall.getReturnData());
			Logger.verifyEquals("request.userId参数验证错误", rechargecall.getMessage(), "错误响应信息验证");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}